package com.thouiot.common.result;


import com.thouiot.common.exception.IErrorCode;

import java.io.Serializable;

/**
 * @description 通用返回结果类
 * @author yuanqi
 * @date 2023/11/16 17:27
 */
public class TiotResult implements Serializable {
    private static final long serialVersionUID = 1138236000811698866L;

    /**
     * 错误码
     */
    private int code;

    /**
     * 返回信息
     */
    private String msg;

    /**
     * 返回结果
     */
    private Object body;

    public TiotResult() {}

    public TiotResult(IErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }

    public TiotResult(int code, Object body) {
        this.code = code;
        this.body = body;
    }

    public TiotResult(int code, String msg, Object body) {
        this.code = code;
        this.msg = msg;
        this.body = body;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getBody() {
        return body;
    }

    public void setBody(Object body) {
        this.body = body;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
